package com.cykj.pos.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import com.cykj.pos.mapper.BizNewsMapper;
import com.cykj.pos.domain.BizNews;
import com.cykj.pos.service.IBizNewsService;

import java.util.List;
import java.util.Map;

/**
 * 新闻Service业务层处理
 *
 * @author weijianbo
 * @date 2021-04-26
 */
@Service
public class BizNewsServiceImpl extends ServiceImpl<BizNewsMapper, BizNews> implements IBizNewsService {

    @Override
    public List<BizNews> queryList(BizNews bizNews) {
        LambdaQueryWrapper<BizNews> lqw = Wrappers.lambdaQuery();
        if (StringUtils.isNotBlank(bizNews.getTitle())){
            lqw.eq(BizNews::getTitle ,bizNews.getTitle());
        }
        if (StringUtils.isNotBlank(bizNews.getNewsContent())){
            lqw.eq(BizNews::getNewsContent ,bizNews.getNewsContent());
        }
        if (bizNews.getUploadTime() != null){
            lqw.eq(BizNews::getUploadTime ,bizNews.getUploadTime());
        }
        if (bizNews.getUploadId() != null){
            lqw.eq(BizNews::getUploadId ,bizNews.getUploadId());
        }
        if (StringUtils.isNotBlank(bizNews.getPictureUrl())){
            lqw.eq(BizNews::getPictureUrl ,bizNews.getPictureUrl());
        }
        if (StringUtils.isNotBlank(bizNews.getJumpAddress())){
            lqw.eq(BizNews::getJumpAddress ,bizNews.getJumpAddress());
        }
        if (bizNews.getSort() != null){
            lqw.eq(BizNews::getSort ,bizNews.getSort());
        }
        if (bizNews.getType() != null){
            lqw.eq(BizNews::getType ,bizNews.getType());
        }
        if (bizNews.getForbidden() != null){
            lqw.eq(BizNews::getForbidden ,bizNews.getForbidden());
        }
        return this.list(lqw);
    }
}
